package com.bytz.modules.cms.reseller.controller;

import com.alibaba.fastjson.JSONObject;
import com.bytz.common.api.vo.Result;
import com.bytz.modules.cms.reseller.service.IResellerPasswordService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "更改密码")
@RequestMapping("/sys/user")
public class PasswordController {

    @Autowired
    private IResellerPasswordService passwordService;

    @RequestMapping(value = "/updatePassword", method = {RequestMethod.PUT, RequestMethod.POST})
    public Result<?> changPassword(@RequestBody JSONObject json) {
        String username = json.getString("username");
        String oldpassword = json.getString("oldpassword");
        String password = json.getString("password");
        String confirmpassword = json.getString("confirmpassword");
        return passwordService.resetPassword(username, oldpassword, password, confirmpassword);
    }

}
